
using System;
using System.Collections;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
 // ERROR: Not supported in C#: OptionDeclaration
namespace NCS_CS
{
	internal partial class frmLogin : System.Windows.Forms.Form
	{

		public bool LoginSucceeded;

		private void cmdCancel_Click(System.Object eventSender, System.EventArgs eventArgs)
		{
			//设置全局变量为 false
			//不提示失败的登录
			LoginSucceeded = false;
			this.Hide();
		}
		public void checkUsr()
		{
			if (ModMain.gDb.loadUser(txtUserName.Text)) {
				//检查正确的密码
				if (ModMain.user1.mpassword == null) {
					LoginSucceeded = true;
					this.Hide();

				} else if (txtPassword.Text == ModMain.user1.mpassword) {
					//将代码放在这里传递
					//成功到 calling 函数
					//设置全局变量时最容易的
					LoginSucceeded = true;
					this.Hide();
				} else {
					MessageBox.Show("无效的密码，请重试!"  , "登录");
					txtPassword.Focus();
					System.Windows.Forms.SendKeys.Send("{Home}+{End}");
				}
			//no this user
			} else {
                MessageBox.Show("无效的用户名，请重试!" , "登录");
				txtUserName.Focus();
				System.Windows.Forms.SendKeys.Send("{Home}+{End}");
			}
		}
		private void cmdOK_Click(System.Object eventSender, System.EventArgs eventArgs)
		{
			//check user
			checkUsr();
		}


		private void frmLogin_Load(System.Object eventSender, System.EventArgs eventArgs)
		{

			//UPGRADE_ISSUE: Global method LoadResPicture was not upgraded. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="6B85A2A7-FE9F-4FBE-AA0C-CF11AC86A305"'
			//Me.Icon = VB6.LoadResPicture("ncscs", VB6.LoadResConstants.ResIcon)
            this.label2.Text = ModMain.program1.tablehead1;
            //if (ModMain.program1.isON) {
            //    if (ModMain.program1.demo == true) {
            //        this.Text = "纳克ON演示版";
            //    } else {
            //        this.Text = "纳克ON";
            //    }
            //} else {
            //    if (ModMain.program1.demo == true) {
            //        //this.Text = NCS_CS.My.MyProject.Application.Info.Title + "演示版";
            //    } else {
            //        //this.Text = NCS_CS.My.MyProject.Application.Info.Title;
            //    }
            //}
            txtUserName.Text = ModMain.program1.lastUser;//gDb.getLastUser();
			//checkUsr()
		}

        private void txtUserName_TextChanged(object sender, EventArgs e)
        {

        }

	}
}
